// const { AsyncSeriesHook }  = require('tapable')
const AsyncSeriesHook = require('./AsyncSeriesHook')

class Lesson {
  constructor(){
    this.hooks = {
      arch: new AsyncSeriesHook(['name'])
    }
  }
  
  tap(){
    this.hooks.arch.tapPromise('node', (name)=>{
      return new Promise((resolve,reject)=>{
        setTimeout(()=>{
          console.log('node',name);
          resolve()
        },1000)
      })
    })
    this.hooks.arch.tapPromise('react', (name)=>{
      return new Promise((resolve,reject)=>{
        setTimeout(()=>{
          console.log('react',name);
          resolve()
        },500)
      })
    })
    // this.hooks.arch.tapAsync('node', (name,cb)=>{
    //   setTimeout(()=>{
    //     console.log('node',name);
    //     cb()
    //   },1000)
    // })
    // this.hooks.arch.tapAsync('react', (name,cb)=>{
    //   setTimeout(()=>{
    //     console.log('react',name);
    //     cb()
    //   },500)
    // })
  }
  start(){
    this.hooks.arch.promise('ldx').then(()=>{
      console.log('end');
    })
    // this.hooks.arch.callAsync('ldx',()=>{
    //   console.log('end');
    // })
  }
}
let l = new Lesson
l.tap()
l.start()